package com.wmeimob.fastboot.jiubei.controller;

import com.github.pagehelper.PageInfo;
import com.wmeimob.fastboot.core.context.PageContext;
import com.wmeimob.fastboot.jiubei.entity.ShopGoods;
import com.wmeimob.fastboot.jiubei.service.ShopGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.concurrent.ExecutorService;

import static java.util.concurrent.Executors.newFixedThreadPool;

/**
 * @author wjt
 * @version 1.0
 * @className ShopGoodsController
 * @description 【商品】控制器
 * @date Fri Aug 28 00:08:28 CST 2020
 **/
@RestController
@RequestMapping("shopGoods")
@Slf4j
public class ShopGoodsController {

    @Resource
    private ShopGoodsService shopGoodsService;
    private static final ExecutorService EXECUTOR = newFixedThreadPool(5);

    /**
     * 商品分页查询
     *
     * @param shopGoods
     * @return
     */
    @GetMapping
    public PageInfo queryForShopGoods(ShopGoods shopGoods) {
        PageContext.startPage();
        shopGoods.setDel(false);
        shopGoods.setGrounding(true);
        return new PageInfo<ShopGoods>(shopGoodsService.list(shopGoods));
    }


    /**
     * 商品查询-<通过id查询>
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ShopGoods queryForShopGoodsById(@PathVariable("id") Object id) {
        return shopGoodsService.queryShopGoodsById(id);
    }

}
